﻿package com.snzflash.components.scroll 
{
	import com.snzflash.components.scroll.Scroll;
	import flash.events.MouseEvent;
	import flash.geom.Rectangle;
	
	/**
	 * Вертикальный скролл
	 * @author firsoff maxim, tel: +79222345364, skype: maxim.firsoff
	 */
	public class VScroll extends Scroll
	{
		
		public function VScroll() 
		{
			super();
			
		}
		
		override protected function onThumbMouseDown(event:MouseEvent):void 
		{
			super.onThumbMouseDown(event);
			_scrollableRect = new Rectangle(thumb.x, 0, 0, background.height - thumb.height);
			////trace(_scrollableRect);
			thumb.startDrag(false, _scrollableRect);
		};
		
		override protected function setPosition():void 
		{
			super.setPosition();
			_position = thumb.y / (background.height - thumb.height);
		};
		
		override public function get position():Number { return super.position; };
		
		override public function set position(value:Number):void 
		{
			super.position = value;
			thumb.y  =  _position * (background.height - thumb.height);
		};
		
	}

}